<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE HTML>
<html>
	
  <head>
    
    <title>选择商品</title>

<link href="<%=basePath %>/warehouse/css/button.css" rel="stylesheet" type="text/css" />
  </head>
  <base target="_self"></base>
  <body>
   
    		<FONT size="6">选择商品</FONT> 
    		
    		
    	
     	
     	
     	<div style="border:1px solid #ffffff; border-top-color:#6cb1f1; background-color: #e5f3ff; width: 100%; bottom: 0px;" >
			
				商品信息
			
  		</div>
  		
  		<div style=" height: 25px;margin: 15px;">
		
		<s:fielderror id="errormessage" />
		
		<form action="javascript:openUrlForDialog('insertreceiptinfo_warehouse.action?searchStr='+$('#searchStrReceiptinfo').attr('value'))" target="_self">
		 查找产品:<input type="text" name="searchStrReceiptinfo" id="searchStrReceiptinfo" size="30" value="<s:property value="searchStr"/>" />
					
				<input type="submit" class="large button blue" value="查找" /> 
		</form>
	    	
		</div>
     	
					 
				
     		<div style="width: 780px;margin: 0px;">
		<table   style= "border:1px solid #ffffff; border-bottom-color:#21a4dc;
    border-left-color:#21a4dc;border-right-color:#21a4dc;border-top-color:#21a4dc;width: 100%;margin: 0px;border-collapse:collapse;">
    	<tr>
   			
   			<td>产品ID</td>
   			
   			<td width="305">产品名称</td>
   			<td>数量</td>
   			<td>单位</td>
   			<td>均价</td>
   			<td>最新进价</td>
   			<td>先择</td>
   		</tr>
   	<s:iterator id="goodsList" value="goodsList" status="sta">
   		<tr>
   			
   			<td><s:property value="#goodsList.id_goods"/></td>
   			
   			
   			<s:if test="#goodsList.number_goods <= 0">
   				<td >
   				<font color="#c0c0c0"><s:property value="#goodsList.name_goods"/></font>
   				 
   				
   				</td>
   			</s:if>
   			<s:else>
   				<td>
   				<a href="javascript:choseGoods('<s:property value="#goodsList.id_goods"/>','<s:property value="#goodsList.name_goods"/>','<s:property value="#goodsList.unit_goods"/>');"><s:property value="#goodsList.name_goods"/></a>
   				
   				
   				
   				</td>
   			</s:else>
   			
   			
   			
   			<td><s:property value="#goodsList.number_goods"/></td>
   			<td><s:property value="#goodsList.unit_goods"/></td>
   			<td><s:property value="#goodsList.average_goods"/></td>
   			<td><s:property value="#goodsList.price_goods"/></td>
   			<%--  <s:if test="#goodsList.number_goods <= 0">
   				<td><button disabled="disabled">选择</button></td>
   			</s:if> 
   			<s:else>
   				<td><button onclick="choseGoods('<s:property value="#goodsList.id_goods"/>','<s:property value="#goodsList.name_goods"/>','<s:property value="#goodsList.unit_goods"/>');" >选择</button></td>
   			</s:else>--%>
   			<td>
   			
   			<s:if test="#goodsList.number_goods <= 0">
   				<td >
   					<button disabled="disabled">选择</button>
   				</td>
   			</s:if>
   			<s:else>
   				<td>
   					<button onclick="choseGoods('<s:property value="#goodsList.id_goods"/>','<s:property value="#goodsList.name_goods"/>','<s:property value="#goodsList.unit_goods"/>');" >选择</button>
   				</td>
   			</s:else>
   			
   			
   			</td>
   		</tr>
     		
    </s:iterator>
     		
     		
     	</table>
     	</div> 
     	
     		<div>
						<%
						
						String url = "insertreceiptinfo_warehouse.action";
						int pageSize = (Integer) request.getAttribute("pageSize");
						int beginPageNum =  (Integer) request.getAttribute("beginPageNum");
						int countRow =  (Integer) request.getAttribute("rowNum");
					    int countPage =(countRow-1)/pageSize+1;
					    int currentPage = countPage - (countRow-beginPageNum)/pageSize;
					    
					    
					    
					 	 
					    
					    String searchstr = (String)request.getParameter("searchStr");//*/
					    if(searchstr != null){
					    	searchstr = java.net.URLDecoder.decode(searchstr, "UTF-8");
					    	//searchstr = java.net.URLEncoder.encode(searchstr,"UTF-8");
					    	//searchstr = searchstr.replaceAll("%", "%25");
					    }else{
					    	searchstr = "";
					    }
					    
					    if((beginPageNum-pageSize+1) >= 1){%>
				    	<a href="javascript:openUrlForDialog('<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum-pageSize) %>')">
								上一页 </a>
				   <% }
					    
					    //beginPageNum =  (pageNum - 1) * pageSize;
						StringBuffer chagePageBuff = new StringBuffer();
						if(countPage >= 2){ 
							int begin = currentPage - 9;
							int end = currentPage + 9;
							
							if(begin < 1){
								begin = 0;
							}
							if(end > countPage){
								end = countPage-1;
							}
							
							
							for(int i=begin;i<countPage;i++){
								
								
								
								
								
								if(beginPageNum == i*pageSize){
									%>
									<%=i+1 %>
									<%
								}else{
									%>
									<a href="javascript:openUrlForDialog('<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=i*pageSize %>')">
									[<%=i+1 %>] </a>
									<%
								}
								
								if(i > end){
									
									break;
									
								}
							}
						}
						
						if((beginPageNum+pageSize-countRow) < 0){%>
				    	<a href="javascript:openUrlForDialog('<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum+pageSize) %>')">
								下一页 </a>
				   		<% }
						
						//*/
						%>
						
						
						
					</div>
					
     		
     	
	     		<div >
	     			<table>
	     				<tr>
	     					
	     					<td width="70">
								  产品ID:
							  </td>
				  
	     					<td id="goodsiddisply"></td>
	     					<td width="70">产品名称:</td>
	     					
	     					<td id="goodsnamedisply"></td>
	     					
	     					<td width="70">单位:</td>
	     					<td id="goodsunitdisply"></td>
	     				</tr>
	     				
	     				<tr>
	     					<td>
								  仓库:
								  
							  </td>
				  			<td id="warehousedisply">
				  				<select id="warehouse">
								  	<option></option>
								  	
								  </select>
				  			</td>
	     					
	     					
	     					<td>数量:</td>
	     					<td><input type="text" id="number" name="number"/></td>
	     					
	     					<td>单价:</td>
	     					<td>
	     					
	     					<input type="text" id="price" name="price"/>
	     					
	     					<input type="hidden"" id="goodsid" name="goodsid">
	     					<input type="hidden"" id="goodsname" name="goodsname">
	     					<input type="hidden"" id="goodsunit" name="goodsunit">
	     					</td>
	     				</tr>
	     				
	     				<tr>
	     					<td>
								  备注:
								  
							  </td>
				  			<td >
				  				<input type="text" id="remark" name="remark" maxlength="512"/>
				  			</td>
	     					
	     					
	     					<td></td>
	     					<td></td>
	     					
	     					<td></td>
	     					<td><input type="button" class="large button green" value="插入产品" onclick="insertGoods()"/></td>
	     				</tr>
	     				</table>
	     		</div>
	     
     	

  
  </body>
  
</html>
